package Demo1;
import java.util.Scanner;

public class JdbcStudent {
    public static void main(String[] args) {
        DbUtil db =new DbUtil();
        db.load();
        Scanner input =new Scanner(System.in);
        System.out.println("请输入姓名:");
        String sname =input.next();
        System.out.println("请输入性别:");
        String sex =input.next();
        System.out.println("请输入手机号:");
        String phone =input.next();
        System.out.println("请输入QQ:");
        String qq =input.next();
        System.out.println("请输入微信号:");
        String wechat =input.next();
        System.out.println("请输入你的年级编号:");
        int gid =input.nextInt();
        System.out.println("请输入入学日期(yyyy-MM-dd):");
        String enterdate =input.next();
        System.out.println("请输入那个城市来的:");
        String fromcity =input.next();
        System.out.println("请输入你的出生日期:");
        String birthday =input.next();
        System.out.println("请输入你的家庭地址:");
        String address =input.next();
        System.out.println("请输入密码:");
        String pass =input.next();
        System.out.println("请输入身份证照片:");
        String idcardpic =input.next();
        boolean flag = db.studentAdd(sname, sex, phone, qq, wechat, gid, enterdate, fromcity, birthday, address, pass, idcardpic);
        System.out.println(flag?"添加成功":"添加失败");





       /* try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        String url ="jdbc:mysql://localhost:3306/kgc76?useSSL=false";
        Connection conn =null;
        PreparedStatement ps =null;
        try {
            conn= DriverManager.getConnection(url,"root","123456");
            Scanner input =new Scanner(System.in);
            System.out.println("请输入姓名:");
            String sname =input.next();
            System.out.println("请输入性别:");
            String sex =input.next();
            System.out.println("请输入手机号:");
            String phone =input.next();
            System.out.println("请输入QQ:");
            String qq =input.next();
            System.out.println("请输入微信号:");
            String wechat =input.next();
            System.out.println("请输入你的年级编号:");
            int gid =input.nextInt();
            System.out.println("请输入入学日期(yyyy-MM-dd):");
            String enterdate =input.next();
            System.out.println("请输入那个城市来的:");
            String fromcity =input.next();
            System.out.println("请输入你的出生日期:");
            String birthday =input.next();
            System.out.println("请输入你的家庭地址:");
            String address =input.next();
            System.out.println("请输入密码:");
            String pass =input.next();
            System.out.println("请输入身份证照片:");
            String idcardpic =input.next();
            String sql ="INSERT INTO `s_student` ( `sname`, `sex`, `telephone`, `qq`, `wechat`, `gradeid`, `enterdate`, `fromcity`, `birthday`, `address`, `pass`, `idcardpic`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
            ps= conn.prepareStatement(sql);
            ps.setString(1,sname);
            ps.setString(2,sex);
            ps.setString(3,phone);
            ps.setString(4,qq);
            ps.setString(5,wechat);
            ps.setInt(6,gid);
            ps.setDate(7, Date.valueOf(enterdate));
            ps.setString(8,fromcity);
            ps.setDate(9,Date.valueOf(birthday));
            ps.setString(10,address);
            ps.setString(11,pass);
            ps.setString(12,idcardpic);
            int num = ps.executeUpdate();
            System.out.printf("添加了%d行。",num);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        finally {
            try {
                ps.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }*/
    }
}
